#include <stdio.h>
#include <assert.h>

float i2f(int a); //int转float
double i2d(int a); //int转double
double f2d(float c); //float转double
float d2f(double b); //double转float
int f2i(float c); //float转int

float i2f(int a){
	return (float)a;
}
double i2d(int a){
	return (double)a;
}
double f2d(float c){
	return (double)c;
}
float d2f(double b){
	return (float)b;
}
int f2i(float c){
	return (int)c;
}

int main(){
	assert(i2f(5)==5.00);//测试正常情况
	assert(i2f(-5)==-5.00);//测试负数int转float
	assert(i2f(16777217)==16777216.0);//测试舍入

	assert(i2d(5)==5.00);//测试正常情况
	assert(i2d(-5)==-5.00);//测试负数int转double

	assert(f2d(5.00)==5.00);//测试正常情况

	assert(d2f(5.00)==5.00);//测试正常情况
	assert(d2f(123.456789e100)!=123.456789e100);//测试溢出

	assert(f2i(5.00)==5);//测试正常情况
	assert(f2i(1.99)==1);//测试向零舍入
	assert(f2i(-1.99)==-1);//测试向零舍入
	//assert(f2i(+1e10)==-21483648);//测试无整数近似值
	printf("%d\n", +1e10);
}
